package com.zx.map.wx.utils;

import com.zx.map.wx.bean.WxMessageBean;
import com.zx.map.wx.context.WxHelperContext;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.text.MessageFormat;

/**
 * Created by bibei on 2017/2/17.
 * 微信通知
 */
public class WXNotifyUtils {
	private static Logger log = Logger.getLogger(WXNotifyUtils.class);

	private final static String APPID = "wx85c32b6dc59c9e5f";
	private final static String APPSECURITY = "340fcc68d68dafe0339f72de9dff3c6e";

	//如果是线下收单 进行通知
	public static void sendNotify(String wxId, String title, String msg) {
		try {
			log.info("账务处理完毕  准备消息推送");
			WxMessageBean wxMessageBean = new WxMessageBean();
			wxMessageBean.setAppId(APPID);
			wxMessageBean.setAppSecu(APPSECURITY);
			wxMessageBean.setTitle(title);

			wxMessageBean.setMessage(msg);
			wxMessageBean.setOpenId(wxId);

			WxHelperContext.getWxHelperContext().sendMessageCore(wxMessageBean);
			log.info("消息推送完毕");
		} catch (IOException e) {
			log.error("消息推送失败", e);
		}
	}

}
